import { Image } from 'antd';
import { useNavigate, useSearchParams } from 'react-router-dom';
import type { YmAddPageLayoutProps, YmColumnsType } from 'ym-design';
import { YmAddPageLayout, YmTable } from 'ym-design';
import { getSignDetailApi, SignDetailListType } from './data';
const { PaneItem } = YmAddPageLayout;
const SignDetail: React.FC<any> = () => {
  const navigator = useNavigate();
  const [searchParam] = useSearchParams();
  const resumeId = searchParam.get('resumeId');
  // 初始化字段定义
  const columns: YmColumnsType<SignDetailListType> = [
    {
      title: '司机姓名',
      dataIndex: 'personName',
      key: 'personName',
      width: 140,
    },
    {
      title: '司机手机号',
      dataIndex: 'personPhone',
      key: 'personPhone',
      width: 140,
    },
    {
      title: '求职状态',
      dataIndex: 'jobSearchStatus',
      width: 140,
      key: 'jobSearchStatus',
      render(value: number) {
        return (
          <div>
            {value == 1
              ? '离职，正在找工作'
              : value == 2
              ? '在职，暂无跳槽打算'
              : value == 3
              ? '在职，看看新机会'
              : '--'}
          </div>
        );
      },
      ellipsis: true,
    },
    {
      title: '签字时间',
      dataIndex: 'signatureTime',
      key: 'signatureTime',
      width: 140,
    },
    {
      title: '签字内容',
      dataIndex: 'signatureContent',
      key: 'signatureContent',
      width: 140,
      render(value, record) {
        return (
          <div>
            {/* <img width={60} height={40} /> */}
            <Image height={45} src={record.signatureContent} />
          </div>
        );
      },
    },
  ];
  const layoutParams: YmAddPageLayoutProps = {
    leftOperation: {
      onBack: () => {
        navigator(-1);
      },
    },
    rightOperationDom: null,
    destroyInactiveTabPane: false,
  };
  return (
    <YmAddPageLayout {...layoutParams}>
      <PaneItem tabKey="tab1" label={''} className="pane_tab1">
        <YmTable
          wrapperStyle={{ background: '#FFF' }}
          columns={columns}
          request={async ({ page }) => {
            const { current = 1, pageSize = 10 } = page ?? {};
            const response = await getSignDetailApi({
              pageIndex: current,
              pageSize,
              resumeId,
            });
            return response;
          }}
          rowKey="personName"
        />
      </PaneItem>
    </YmAddPageLayout>
  );
};
export default SignDetail;
